﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ednews.ascx.cs" Inherits="admin_ednews" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<style type="text/css">
    .style1
    {
        width: 119px;
    }
    .style2
    {
        width: 618px;
    }
</style>
<center>
<table width="100%">
    <tr>
        <td class="style1">Ngôn ngữ</td>
        <td class="style2">
            <asp:DropDownList ID="ddlLang" runat="server" AutoPostBack="True" 
                DataSourceID="SqlDataSource3" DataTextField="lang" DataValueField="id" 
                Enabled="false">
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
                SelectCommand="SELECT [id], [lang] FROM [Languages]">
                <DeleteParameters>
                    <asp:Parameter Name="id" Type="String" />
                    <asp:Parameter Name="lang" Type="String" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="id" Type="String" />
                    <asp:Parameter Name="lang" Type="String" />
                </InsertParameters>
            </asp:SqlDataSource>
            </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ControlToValidate="ddlLang">Chưa Chọn Ngôn Ngữ</asp:RequiredFieldValidator>
            </td>
    </tr>
    <tr>
        <td class="style1">Loại tin: </td>
        <td class="style2">
            <asp:DropDownList ID="newstype" runat="server" DataSourceID="SqlDataSource1" 
                DataTextField="description" DataValueField="id" AutoPostBack="True" 
                Enabled="False">
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
                
                SelectCommand="SELECT [id], [description] FROM [NewsType] ORDER BY [description] DESC"></asp:SqlDataSource>
            </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                ErrorMessage="*" ControlToValidate="newstype">Chưa chọn Loại Tin</asp:RequiredFieldValidator>
            </td>
    </tr>
    <tr>
        <td class="style1">Tiêu đề: </td>
        <td class="style2">
            <asp:TextBox ID="title" runat="server"></asp:TextBox>
            </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                ErrorMessage="*" ControlToValidate="title">Chưa  Nhập Tiêu Đề</asp:RequiredFieldValidator>
            </td>
    </tr>
    <tr>
        <td class="style1">Miêu tả: </td>
        <td class="style2">
            <asp:TextBox ID="des" runat="server"></asp:TextBox>
        </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                ErrorMessage="*" ControlToValidate="des">Chưa Nhập Miêu Tả</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="style1">Ảnh: </td>
        <td class="style2">
            <asp:FileUpload ID="fulImage" runat="server" />
        </td>
        <td>
            <asp:Label ID="lbImage" runat="server" ForeColor="Red"></asp:Label>
        </td>
    </tr>
    <tr>
        <td class="style1">Nội dung: </td>
        <td class="style2">
            <fckeditorv2:fckeditor ID="fckContent" runat="server" BasePath="~/fckeditor/" 
                Height="300px">
            </fckeditorv2:fckeditor>
        </td>
        <td>
            <asp:HiddenField ID="hdfContent" runat="server" />
            <asp:HiddenField ID="hdfNewID" runat="server" />
            <asp:HiddenField ID="hdfImage" runat="server" />
        </td>
    </tr>
     <tr>
        <td class="style1">&nbsp;</td>
        <td class="style2">
            &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td class="style1"><center></center></td>
        <td class="style2"><asp:Button runat="server" ID="addbt" Text="Cập nhật" 
                onclick="addbt_Click"/></td>
        <td>&nbsp;</td>
    </tr>
</table>
</center>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
    DeleteCommand="DELETE FROM [News] WHERE [id] = @id AND [lang] = @lang" 
    InsertCommand="INSERT INTO [News] ([id], [lang], [title], [description], [content], [newsTypeId]) VALUES (@id, @lang, @title, @description, @content, @newsTypeId)" 
    SelectCommand="SELECT * FROM [News]" 
    UpdateCommand="UPDATE [News] SET [title] = @title, [description] = @description, [content] = @content, [newsTypeId] = @newsTypeId, [imageUrl] = @imageUrl WHERE [id] = @id AND [lang] = @lang">
    
    <UpdateParameters>
        <asp:ControlParameter ControlID="title" Name="title" PropertyName="Text" 
            Type="String" />
        <asp:ControlParameter ControlID="des" Name="description" PropertyName="Text" 
            Type="String" />
        <asp:ControlParameter ControlID="hdfContent" Name="content" 
            PropertyName="Value" Type="String" />
        <asp:ControlParameter ControlID="newstype" Name="newsTypeId" 
            PropertyName="SelectedValue" Type="Int64" />
        <asp:ControlParameter ControlID="hdfNewID" Name="id" PropertyName="Value" 
            Type="Int64" />
        <asp:ControlParameter ControlID="ddlLang" Name="lang" 
            PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="hdfImage" Name="imageUrl" 
            PropertyName="Value" Type="String" />
    </UpdateParameters>
   
</asp:SqlDataSource>
